package com.liangwj.springbootdesignpatterns.structureTypePatterns.composite.demo_1;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * <b>Description:</b> 组合模型类 <br/>
 * 该类带有 Employee对象的列表
 * @author Lingwenjun
 * @date 2019/1/28-11:10
 * @version 1.0
 */
public class Employee {
    private String empName;

    private String empDept;

    private BigDecimal salary;

    private List<Employee> subordinates;

    //construct
    public Employee(String empName, String empDept, BigDecimal salary) {
        this.empName = empName;
        this.empDept = empDept;
        this.salary = salary;
        this.subordinates = new ArrayList<>();
    }

    public void add(Employee employee) {
        subordinates.add(employee);
    }

    public void remove(Employee employee) {
        subordinates.remove(employee);
    }

    public List<Employee> getSubordinates() {
        return subordinates;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "empName='" + empName + '\'' +
                ", empDept='" + empDept + '\'' +
                ", salary=" + salary +
                '}';
    }
}
